Card = fgui.extension_class(GButton)

--注意这里不是构造函数，是当组件已经（通过XML）构建完毕后调用的
function Card:ctor()
	self._back = self:GetChild("n0");
	self._front = self:GetChild("icon");
	self._front.visible = false;
	self.tname = "";

	print("Card ctor: ", self);
end

function Card:GetOpend()
	-- body
	return self._front.visible;
end

function Card:SetOpend(b)
	-- body
	if (DOTween.IsTweening(self)) then
		DOTween.Kill(this);
	end

	self._front.visible = value;
	self._back.visible = not value;
end

function Card:SetOpend(b)
	self._front.displayObject.perspective = true;
	self._back.displayObject.perspective = true;
end

function Card:Turn()
	if (DOTween.IsTweening(self)) then
		return;
	end

	self.toOpen = not self._front.visible;

	print(self._front);
	--print("Getter: ", self.Extension_funGetter);
	--print("Setter: ", self.Extension_funSetter);

	local _Self = self;

	local MyExtension_funSetter = function (x)
		print("Setter...", x, _Self);
		-- body
		if (_Self.toOpen) then
			_Self._back.rotationY = x;
			_Self._front.rotationY = -180 + x;
			if (x > 90) then
				_Self._front.visible = true;
				_Self._back.visible = false;
			end
		else
			_Self._back.rotationY = -180 + x;
			_Self._front.rotationY = x;
			if (x > 90) then
				_Self._front.visible = false;
				_Self._back.visible = true;
			end
		end
	end
	
	DOTween.To(DG.Tweening.Core.DOGetter_float(self.Extension_funGetter), DG.Tweening.Core.DOSetter_float(MyExtension_funSetter), 180, 0.8):SetTarget(self):SetEase(DG.Tweening.Ease.OutQuad);

	

end

function Card:Extension_funGetter()
	return 0;
end



function Card:SetPerspective()
	self._front.displayObject.perspective = true;
	self._back.displayObject.perspective = true;
end